package cn.edu.scau.cmi.chensixiao.javaFX;

import java.net.URL;
import java.util.ResourceBundle;

import cn.edu.scau.cmi.chensixiao.singleton.Chairman;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;

public class SingletonController implements Initializable{

	@FXML
	private Button creatButton;
	
	@FXML
	private TextField nameText;
	
	@FXML
	private TextArea messageText;
	
	@Override
	public void initialize(URL location,ResourceBundle resources) {
		nameText.setText(Chairman.getInstance("").getName());
	}
	
	@FXML
	public void buttonOnClick() {
		System.out.println("button clicked");
		String name = nameText.getText();
		System.out.println(name);
		Chairman chairman = Chairman.getInstance(name);
		if(chairman.getName() != name) {
			messageText.setText("主席只能有一个！是" + chairman.getName() + "\n地址为:  " +chairman.getInstance(name));

		}
		System.out.println(chairman.getName());


	}
}
